//
//  makeUpTableViewCell.m
//  HaoDeCaiFu
//
//  Created by 张玉鹏 on 2017/11/17.
//  Copyright © 2017年 郑开宏. All rights reserved.
//

#import "makeUpTableViewCell.h"

@implementation makeUpTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setBuyMoneyTwo:(CGFloat)buyMoneyTwo{
    _buyMoneyTwo = buyMoneyTwo;;
}

-(NSString *)FundType:(NSString *)fundType
{
    if ([fundType isEqualToString:@"MM"]) {
        return  @"货币型";
    }
    else if ([fundType isEqualToString:@"BOND"]) {
        return @"债券型";
    }
    else if ([fundType isEqualToString:@"MIXED"]) {
        return @"混合型";
    }
    else if ([fundType isEqualToString:@"CP"]) {
        return @"保本型";
    }
    else if ([fundType isEqualToString:@"EQ"]) {
        return @"股票型";
    }
    else if ([fundType isEqualToString:@"AI"]) {
        return @"另类型";
    }
    else if ([fundType isEqualToString:@"INDEX"]) {
        return @"指数型";
    }
    else if ([fundType isEqualToString:@"ST"]) {
         return @"分级型";
    }
    else if ([fundType isEqualToString:@"UNKNOW"]) {
        return @"其他";
    }else{
        return @"其他";
    }
}

- (void)setDataDict:(NSDictionary *)dataDict{
    _dataDict = dataDict;
    self.name.text=dataDict[@"fundName"];
    self.numStyle.text=[NSString stringWithFormat:@"%@ %@",dataDict[@"fundCode"],[self FundType:dataDict[@"fundType"]]];
    if ([dataDict[@"proportion"] isKindOfClass:[NSNull class]]) {
        self.shouyi.text = @"--";
        self.shouyi.textColor = [UIColor redColor];
        self.zhanbi.textColor = ZKcolor(170, 170, 170);
        self.zhanbi.text = @"--";
    }else{
        NSNumber *proportion = dataDict[@"proportion"];
        self.shouyi.text=[NSString stringWithFormat:@"%.2f%%",proportion.doubleValue];
        self.shouyi.textColor = [UIColor redColor];
        self.zhanbi.textColor = ZKcolor(170, 170, 170);
        CGFloat f = _buyMoneyTwo * proportion.doubleValue / 100.0;
        self.zhanbi.text = [NSString stringWithFormat:@"%.2f元",f];;
    }
    
}

-(void)setDetail:(portfolioDetail *)detail
{
    
        self.name.text=detail.fundName;
        self.numStyle.text=[NSString stringWithFormat:@"%@ %@",detail.fundCode,detail.fundType];
        self.zhanbi.text=[NSString stringWithFormat:@"%.2f%%",[detail.proportion floatValue]];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
